import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String b = in.nextLine();
            b = b.toUpperCase();
            String a = in.nextLine();
            a = a.toUpperCase();
            Set<Character> set =new HashSet<Character>();
            Set<Character> set2 =new HashSet<Character>();
            for(int i = 0;i < a.length();i++){
                if(!set.contains(a.charAt(i))){
                    set.add(a.charAt(i));
                }
            }
            for(int i = 0;i < b.length();i++){
                if(!set.contains(b.charAt(i)) && !set2.contains(b.charAt(i))){
                    char x = b.charAt(i);
                    set2.add(b.charAt(i));
                    System.out.print(b.charAt(i));
                }
                //System.out.print(b.charAt(i));
            }
            System.out.println();
        }
    }
}